var details = {};
var page = 1;

function getStaff() {
	$.ajax({
		type: 'get',
		url: baseUrl + 'hsent-xxyl-user/staffs/findBasicStaffsDetail',
		async: false,
		data: {
			shopId: '0600400007120190215',
			staffsId: 1
		},
		success: function(res) {

			details.staff = res.data.basicStaffsBaseModel;
			details.list = res.data.shopAndGoodsModel.goodsList;
			details.picUrl = picUrl

			return details;

		}
	});
	return details;

}
//获取店铺信息
function getShop() {
	var shop;
	$.ajax({
		type: 'get',
		url: baseUrl + 'hsent-xxyl-user/store/showBasicInformation',
		async: false,
		data: {
			shopId: '0600400007120190215'
		},
		success: function(res) {

			details.shop = res.data
			return details;

		}
	})
	return details;

}
//获取店铺评论头部
function getCommentsTop() {
	var commentsTop;
	$.ajax({
		type: "get",
		url: baseUrl + 'hsent-xxyl-user/store/selectNums',
		async: false,
		data: {
			shopId: '0600400007120190215'
		},
		success: function(res) {

			details.commentsTop = res.data;
			return details;
		}
	});
	return details;

}
var str;
$('#staff').on('click', '.com-category span', function(e) {
	$(this).css({
		'background': 'rgb(35,106,173)',
		'color': '#fff'
	}).siblings().css({
		'background': '#fff',
		'color': 'rgb(16,16,16)'
	})
	str = e.target.innerHTML.split('(')[0]
	getComments(str, 1)

})
//获取更多评价
$('#staff').on('click', '.comments-more', function() {
    var that = $(this);
	page++;
	$.ajax({
		type: "get",
		url: baseUrl + 'hsent-xxyl-user/store/SelectAllEvaluation',
		async: false,
		data: {
			page: page,
			index: 3,
			status: '全部',
			shopId: '0600400007120190215'
		},
		success: function(res) {
			 
			if(res.data.length > 0) {
				var arr = res.data
				var com = details.comments.concat(arr)
				details.comments = com;
                
				getData()
            	 
			} else {
			   that.html('无更多评价')
			   return;
			}
           
		}
	});
	
})
//获取用户评论
function getComments(state, page) {

	$.ajax({
		type: "get",
		url: baseUrl + 'hsent-xxyl-user/store/SelectAllEvaluation',
		async: false,
		data: {
			page: page,
			index: 3,
			status: state,
			shopId: '0600400007120190215'
		},
		success: function(res) {
			details.comments = res.data;
			getData()
		}
	});

}

var orderCon;

function getData() {
	orderCon = template('test', details);
	document.getElementById('staff').innerHTML = orderCon;
}

//getData('全部');
//基本信息
$(function() {

	var id = window.location.search.substr(4);
	getStaff(); //获取员工信息
	getShop(); //获取店铺信息
	getCommentsTop(); //获取评论头部
	getComments('全部', 1);
	getData();

})

function jump(goods, staff) {
	console.log(goods, staff);
}